using IcsSEMCtrl.Db;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
namespace Lifter.Device.Unit
{
	public class NextLocation
	{
		private const string CLASS = "LifterPort";
		private string subSystemId = "";
		private int nextLocationID;
		private string nextLoc_HostId = "";
		private string subSystemPLCID = "";
		public string SubSystemId
		{
			get
			{
				return this.subSystemId;
			}
			set
			{
				this.subSystemId = value;
			}
		}
		public int NextLocationID
		{
			get
			{
				return this.nextLocationID;
			}
			set
			{
				this.nextLocationID = value;
			}
		}
		public string NextLoc_HostId
		{
			get
			{
				return this.nextLoc_HostId;
			}
			set
			{
				this.nextLoc_HostId = value;
			}
		}
		public string SubSystemPLCID
		{
			get
			{
				return this.subSystemPLCID;
			}
			set
			{
				this.subSystemPLCID = value;
			}
		}
		public static Dictionary<string, NextLocation> LoadNextLocationInfo(string elementId)
		{
			Dictionary<string, NextLocation> dictionary = new Dictionary<string, NextLocation>();
			DBConnection connection = DBControl.GetConnection();
			string sqlstring = "select SUBSYSTEMID,NEXTLOCATIONID,NEXTLOCATIONHOSTID,SUBSYSTEMPLCID  from NEXTLOCATION_INFO where SUBSYSTEMID ='" + elementId + "'";
			SqlDataReader sqlDataReader = connection.ExecuteQuery(sqlstring);
			while (sqlDataReader.Read())
			{
				NextLocation nextLocation = new NextLocation();
				nextLocation.subSystemId = (string)sqlDataReader["SUBSYSTEMID"];
				nextLocation.nextLocationID = (int)sqlDataReader["NEXTLOCATIONID"];
				nextLocation.nextLoc_HostId = (string)sqlDataReader["NEXTLOCATIONHOSTID"];
				nextLocation.subSystemPLCID = (string)sqlDataReader["SUBSYSTEMPLCID"];
				dictionary.Add(nextLocation.nextLocationID.ToString(), nextLocation);
			}
			if (sqlDataReader != null)
			{
				sqlDataReader.Close();
			}
			DBControl.RemoveDBConection(connection);
			return dictionary;
		}
	}
}
